package com.example.jpatest.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class HttpAspect {
    @Pointcut("execution(* com.example.jpatest.webapi.StudentRestController.*(..))")
    public void log() {
    }

    @Before("log()")
    public void doBefore() {
        System.out.println("准备开始....");
    }

    @After("log()")
    public void doAfter() {
        System.out.println("执行结束，准备返回...");
    }

    @AfterReturning(returning = "object", pointcut = "log()")
    public void afterR(Object object) {
        log.info("response={}", object);
    }
}
